<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>
<script>
  function monkeysAndPeach(n) {
    if (n<=1) {
        return false
    }
    var peaches = 0; //最初的桃子数
    for (var i = 1;; i++) {
        var peaches = n * i + 1;
        for (monkeys = 1; monkeys < n; monkeys++) {
            peaches = peaches / (n-1) * n + 1;
            //用第五个猴子拿之前的桃子数反推第四个猴子拿桃子前的数量
            //反推四次 拿走一份后 剩下4/5份桃子 反推就是 除以 4/5 即*5/4
        }
        if (peaches % n == 1) {
            // console.log(peaches);
            break;//结束循环
 
        }
    }
    // console.log(peaches);
    return peaches
  }
  console.log(monkeysAndPeach(2))
</script>
